package com.cooba.activitys;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cooba.R;
import com.cooba.bean.DrawOutRecordBean;
import com.cooba.bean.RedWalletDetailBean;
import com.cooba.utils.CommonUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DrawOutDetailActivity extends AppCompatActivity {

    private DrawOutRecordBean.DrawOutRecordInfo drawoutrecordinfo;
    private ImageButton time_line_back_btn;
    private TextView time_line_pay_phone, time_line_pay_name, time_line_draw_out_money;
    private TextView time_line_start_time, time_line_start_circle, time_line_start_status_tv;
    private TextView time_line_center_time, time_line_center_circle, time_line_center_status_tv;
    private TextView time_line_end_time, time_line_end_circle, time_line_end_status_tv;
    private TextView time_line_current_status_tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.time_line_layout);
        drawoutrecordinfo = (DrawOutRecordBean.DrawOutRecordInfo) getIntent().getSerializableExtra("drawoutbean");
        initView();
        initData();
        setListener();
    }

    private void setListener() {
        time_line_back_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void initData() {
        time_line_pay_phone.setText("支付宝帐号: " + drawoutrecordinfo.getUser_id().substring(0,3)+"****"+drawoutrecordinfo.getUser_id().substring(7));
        time_line_pay_name.setText("姓名: " + drawoutrecordinfo.getName());
        time_line_draw_out_money.setText("提现金额: " + drawoutrecordinfo.getMoney());
        setTimeLineData();
    }

    private void setTimeLineData() {
        time_line_start_time.setText(drawoutrecordinfo.getTime().substring(2,16));
        time_line_start_status_tv.setText("申请提现成功");
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date currenttime = new Date();
        String currentdatestr = formatter.format(currenttime);
        switch (Integer.parseInt(drawoutrecordinfo.getStatus1())) {
            case 0:
                RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) time_line_center_circle.getLayoutParams();
                params.height = CommonUtil.dip2px(this, 30);
                params.width = CommonUtil.dip2px(this, 30);
                time_line_center_circle.setLayoutParams(params);
                time_line_center_circle.setBackground(getResources().getDrawable(R.drawable.circle_bg1));
                time_line_center_time.setText(currentdatestr.substring(2, 16));
                time_line_center_status_tv.setText("正在审核");
                time_line_center_status_tv.setTextColor(getResources().getColor(R.color.frame));
                time_line_current_status_tv.setText("提现申请正在审核中");
                time_line_current_status_tv.setTextColor(getResources().getColor(R.color.frame));
                break;
            case 1:
                //time_line_center_status_tv.setVisibility(View.INVISIBLE);
                time_line_center_time.setVisibility(View.INVISIBLE);
                //time_line_center_circle.setVisibility(View.INVISIBLE);
                time_line_center_status_tv.setText("正在审核");
                RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) time_line_end_circle.getLayoutParams();
                params1.height = CommonUtil.dip2px(this, 30);
                params1.width = CommonUtil.dip2px(this, 30);
                time_line_end_circle.setLayoutParams(params1);
                time_line_end_circle.setBackground(getResources().getDrawable(R.drawable.circle_bg1));
                time_line_end_time.setText(drawoutrecordinfo.getDetail_time().substring(2, 16));
                time_line_end_status_tv.setText("提现成功");
                time_line_end_status_tv.setTextColor(getResources().getColor(R.color.frame));
                time_line_current_status_tv.setText("提现操作已完成");
                time_line_current_status_tv.setTextColor(getResources().getColor(R.color.frame));
                break;
            case 2:
                //time_line_center_status_tv.setVisibility(View.INVISIBLE);
                time_line_center_time.setVisibility(View.INVISIBLE);
                //time_line_center_circle.setVisibility(View.INVISIBLE);
                time_line_center_status_tv.setText("正在审核");
                RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) time_line_end_circle.getLayoutParams();
                params2.height = CommonUtil.dip2px(this, 30);
                params2.width = CommonUtil.dip2px(this, 30);
                time_line_end_circle.setLayoutParams(params2);
                time_line_end_circle.setBackground(getResources().getDrawable(R.drawable.circle_bg1));
                time_line_end_time.setText(drawoutrecordinfo.getDetail_time().substring(2, 16));
                time_line_end_status_tv.setText("提现失败");
                time_line_end_status_tv.setTextColor(getResources().getColor(R.color.red));
                time_line_current_status_tv.setText(drawoutrecordinfo.getRemark());
                time_line_current_status_tv.setTextColor(getResources().getColor(R.color.red));
                break;
            default:
                break;
        }


    }

    private void initView() {
        time_line_back_btn = (ImageButton) findViewById(R.id.time_line_back_ib);
        time_line_pay_phone = (TextView) findViewById(R.id.time_line_pay_phone);
        time_line_pay_name = (TextView) findViewById(R.id.time_line_pay_name);
        time_line_draw_out_money = (TextView) findViewById(R.id.time_line_draw_out_money);
        time_line_start_time = (TextView) findViewById(R.id.time_line_start_time);
        time_line_start_circle = (TextView) findViewById(R.id.time_line_start_circle);
        time_line_start_status_tv = (TextView) findViewById(R.id.time_line_start_status_tv);
        time_line_center_time = (TextView) findViewById(R.id.time_line_center_time);
        time_line_center_circle = (TextView) findViewById(R.id.time_line_center_circle);
        time_line_center_status_tv = (TextView) findViewById(R.id.time_line_center_status_tv);
        time_line_end_time = (TextView) findViewById(R.id.time_line_end_time);
        time_line_end_circle = (TextView) findViewById(R.id.time_line_end_circle);
        time_line_end_status_tv = (TextView) findViewById(R.id.time_line_end_status_tv);
        time_line_current_status_tv = (TextView) findViewById(R.id.time_line_current_status_tv);
    }
}
